<!DOCTYPE html>
<html>
<title>Test that player state is correctly reset.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../media-controls.js"></script>
<video controls width=400></video>
<script>
async_test(t => {
  const video = document.querySelector('video');
  let count = 0;

  checkControlsHasClasses(video, ['phase-pre-ready', 'state-no-source', 'use-default-poster']);

  video.onplaying = t.step_func(() => {
    checkControlsHasClasses(video, ['phase-ready', 'state-playing']);

    count++;
    if (count == 2)
      t.done();
    else
      video.pause();
  });

  video.onpause = t.step_func(() => {
    checkControlsHasClasses(video, ['phase-ready', 'state-stopped']);
    video.src = "../content/test.ogv";
    video.play();
  });

  video.src = "../content/counting.ogv";
  video.play();
});
</script>
</html>
